﻿<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>网站标题</title>
<script type="text/javascript" src="/js/lib/jquery-1.6.4.min.js"></script>
</head>
<body>

<!--dom-->
<label><input type="checkbox" id="check" onClick="selectAll(this,'ids[]')" />全选/取消</label><br />
<input type="checkbox" name="ids[]" />
<input type="checkbox" name="ids[]" />
<input type="checkbox" name="ids[]" />
<!--/dom-->
	

<script type="text/javascript">
<!--javascript-->
/**
* @author hongz1125@gmail.com
* @title 全选/取消全选
* @param obj Object checkbox对象本身
* @param string name 列表check名称,如 uid[]
*/
function selectAll(obj,name) {
	if ($(obj).attr("checked") == "checked"){
		$("input[name='"+name+"']").each(function() {
			this.checked=true;
		});
	} else {
		$("input[name='"+name+"']").each(function() {
			this.checked=false;
		});
	}
}
<!--/javascript-->
</script>
</body>
</html>



